/********************************************************************

Write Date: 2011/06/02
Author: Deng Nianchen
>>>> Implement OOPObject

Modify Date: 2011/07/16
Author: Deng Nianchen
>>>> Fix bugs on handling operator new[]

*********************************************************************/
#ifndef OOP_OBJECT_H
#define OOP_OBJECT_H
#include "OOPUtilsGlobal.hpp"



_OOPUTILS_BEGIN



class OOPPtrHelper;


/**************************************************************************************************
 * <summary> Purpose: OOPObject is the root class of all classes in this 
 * 					 framework. It provides support for strong smart pointer 
 * 					 OOPPtr by recording reference number and whether it's on 
 * 					 the heap or stack. Thus all limits in using HeapPtr are 
 * 					 removed if you use OOPPtr with object of OOPObject.
 * 					 I recommend you to let your classes inherit OOPObject to 
 * 					 gain the advantages of OOPPtr. It will let you feel free 
 * 					 with C/C++ pointer.
 * 					 Thread-Safe: the class is not thread-safe. </summary>
 * 
 * <remarks>  Deng Nianchen, 2011/06/02. </remarks>
 **************************************************************************************************/

class _EXPORT_UTILS_CLASS OOPObject
{

	friend class OOPPtrHelper;

public:

	enum AllocInfo { ON_STACK, ON_HEAP, ARRAY_ON_HEAP };

	OOPObject ();

	OOPObject (const OOPObject & obj);

	virtual ~OOPObject ();

	static void * operator new (size_t size);

	static void * operator new[] (size_t size);

	bool isOnHeap () const;

	bool isArrOnHeap () const;

	int getRefNum () const;

private:

	AllocInfo _allocInfo;

	int _refNum;

	OOPObject * _pRefAffectObj;

};



_OOPUTILS_END



#endif